const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require('path');
module.exports={
  entry:{
    "index":"./src/router.js"
  },
  output:{
    publicPath:".",
    filename:"js/[name].js",
    path:path.resolve(__dirname,'../dist'),  //获取输出路径
  }, 
  module:{
    rules:[
      {
        test:/\.tsx?$/,
        use:'ts-loader',
        exclude:/node_modules/
      },
      {
        test:/\.css$/,
        use:[{
          loader:MiniCssExtractPlugin.loader,
          options:{publicPath:"../"}
        },"css-loader"]
      },
      {
        test:/\.jpg$|\.png$|\.gif$/,
        use:"file-loader"
      }
    ]
  },
  resolve:{
    extensions:[".ts",".js",".tsx"]
  },
  plugins:[
    new HtmlWebpackPlugin({
      template:"./src/index.html",
      filename:"./index.html",
      chunks:["index"]
    }),
    new MiniCssExtractPlugin({
      filename:"css/[name].css"
    })
  ]
}